package com.dxf.sysadmin.controller;

import com.dxf.common.utils.ResultJson;
import com.dxf.sysadmin.entity.po.TreeSelectPo;
import com.dxf.sysadmin.service.SysMenuService;
import com.dxf.sysadmin.utils.MenuTree;
import com.dxf.sysadmin.utils.TreeHpler;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/admin/menu")
@Api(tags  = "SysMenuController|菜单控制器")
public class SysMenuController {
    @Autowired
    private SysMenuService sysMenuService;

    /**
     * @Description: 获取菜单treeTable数据
     */
    @GetMapping("getMenus")
    @ApiOperation("获取菜单treeTable数据")
    public ResultJson getMenus(){
        return sysMenuService.getMenus();
    }

    /**
     * @Description: 菜单添加时父级选择的SelectTree数据
     */
    @GetMapping("selectTree")
    @ApiOperation("菜单添加时父级选择的SelectTree数据")
    public ResultJson selectTree(){
        return sysMenuService.selectTree();
    }

    /**
     * @Description: 提交menuForm添加或修改菜单(操作)
     */
    @PostMapping("menuForm")
    @ApiOperation("提交menuForm添加或修改菜单(操作)")
    public ResultJson menuForm(@RequestBody TreeSelectPo po){
        return sysMenuService.menuForm(po);
    }

    /**
     * @Description: 更具MenuTree对象判断删除菜单（操作）
     */
    @PostMapping("delete")
    @ApiOperation(value = "更具MenuTree对象判断删除菜单（操作）")
    public ResultJson deleteMenu(@RequestBody MenuTree tree){
        return sysMenuService.deleteMenu(tree);
    }

    /**
     * @Description: 更具token获取菜单
     */
    @GetMapping("menuVo/{token}")
    @ApiOperation(value = "更具token获取菜单")
    public ResultJson menuVo(@PathVariable String token){
        return sysMenuService.menuVo(token);
    }

}
